package com.xuecheng.order.job;

import cn.hutool.core.date.DateUtil;
import com.xuecheng.order.service.OrdersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

// 普通java类
@Component
@Slf4j
public class OrdersJob {

    @Autowired
    private OrdersService ordersService;

    // 指定时间规则
    // @Scheduled(fixedDelay = 5000)
    @Scheduled(cron = "0/600 * * * * ?")
    public void clearOrders(){
        log.info("定时清理超时订单：{}",DateUtil.date());
        ordersService.clearOrders();
    }
}